﻿using System;
using System.Text;

namespace Smart.Web.Mobile
{
    /// <summary>
    /// 
    /// </summary>
    public class MobileOutputEncoding : Encoding
    {
        private readonly Encoding dmuuyEncoding;
        private readonly Encoding outputEncoding;

        /// <summary>
        /// 
        /// </summary>
        public MobileOutputEncoding(Encoding dmuuyEncoding, Encoding outputEncoding)
        {
            this.dmuuyEncoding = dmuuyEncoding;
            this.outputEncoding = outputEncoding;
        }

        //--------------------------------------------------------------------------------//
        // 変換
        //--------------------------------------------------------------------------------//

        /// <summary>
        /// 
        /// </summary>
        /// <param name="chars"></param>
        /// <param name="index"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public override int GetByteCount(char[] chars, int index, int count)
        {
            return this.dmuuyEncoding.GetByteCount( chars, index, count );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="chars"></param>
        /// <param name="charIndex"></param>
        /// <param name="charCount"></param>
        /// <param name="bytes"></param>
        /// <param name="byteIndex"></param>
        /// <returns></returns>
        public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
        {
            return this.dmuuyEncoding.GetBytes( chars, charIndex, charCount, bytes, byteIndex );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="bytes"></param>
        /// <param name="index"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public override int GetCharCount(byte[] bytes, int index, int count)
        {
            return this.dmuuyEncoding.GetCharCount( bytes, index, count );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="bytes"></param>
        /// <param name="byteIndex"></param>
        /// <param name="byteCount"></param>
        /// <param name="chars"></param>
        /// <param name="charIndex"></param>
        /// <returns></returns>
        public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
        {
            return this.dmuuyEncoding.GetChars( bytes, byteIndex, byteCount, chars, charIndex );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="charCount"></param>
        /// <returns></returns>
        public override int GetMaxByteCount(int charCount)
        {
            return this.dmuuyEncoding.GetMaxByteCount( charCount );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="byteCount"></param>
        /// <returns></returns>
        public override int GetMaxCharCount(int byteCount)
        {
            return this.dmuuyEncoding.GetMaxCharCount( byteCount );
        }

        //--------------------------------------------------------------------------------//
        // 委譲
        //--------------------------------------------------------------------------------//

        /// <summary>
        /// 
        /// </summary>
        public override string WebName
        {
            get { return this.outputEncoding.WebName; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string EncodingName
        {
            get { return this.outputEncoding.EncodingName; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string HeaderName
        {
            get { return this.outputEncoding.HeaderName; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string BodyName
        {
            get { return this.outputEncoding.BodyName; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override int CodePage
        {
            get { return this.outputEncoding.CodePage; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override int WindowsCodePage
        {
            get { return this.outputEncoding.WindowsCodePage; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override byte[] GetPreamble()
        {
            return this.outputEncoding.GetPreamble();
        }

        //--------------------------------------------------------------------------------//
        // 委譲
        //--------------------------------------------------------------------------------//

        /// <summary>
        /// 
        /// </summary>
        public override bool IsBrowserDisplay
        {
            get { return this.outputEncoding.IsBrowserDisplay; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override bool IsBrowserSave
        {
            get { return this.outputEncoding.IsBrowserSave; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override bool IsMailNewsDisplay
        {
            get { return this.outputEncoding.IsMailNewsDisplay; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override bool IsMailNewsSave
        {
            get { return this.outputEncoding.IsMailNewsSave; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override bool IsSingleByte
        {
            get { return this.outputEncoding.IsSingleByte; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public override bool IsAlwaysNormalized(NormalizationForm form)
        {
            return this.outputEncoding.IsAlwaysNormalized( form );
        }
    }
}
